

<!DOCTYPE html>
<html lang="en">

<div th:include="common/commonjs :: atmCommonjs"></div>
<body data-type="index" class="theme-white">

    <div class="am-g tpl-g">
        <!-- 头部 -->
        <div th:include="common/head :: atmHeader"></div>
        <!-- 风格切换 -->
        
        <!-- 侧边导航栏 -->
        <div th:include="common/left :: atmLeft"></div>

        <!-- 内容区域 -->
        <div class="tpl-content-wrapper">

            <div class="row-content am-cf">
                <div class="row  am-cf">
                    
                    <div class="row">

                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl">存钱</div>
                                <div class="widget-function am-fr">
                                    <a href="javascript:;" class="am-icon-cog"></a>
                                </div>
                            </div>
                            <div class="widget-body am-fr">

                                <form class="am-form tpl-form-line-form">

                                    <div class="am-form-group">
                                        <label for="cardId" class="am-u-sm-3 am-form-label">银行卡 <span class="tpl-form-line-small-title"></span></label>
                                        <div class="am-u-sm-9">
                                            <select id="cardId" data-am-selected="{searchBox: 1}">
                                                <option value="no">请选择银行卡</option>
                                                <option value="b">622***009</option>
                                                <option value="o">622***007</option>
                                            </select>

                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <label for="password" class="am-u-sm-3 am-form-label">密码 <span class="tpl-form-line-small-title"></span></label>
                                        <div class="am-u-sm-9">
                                            <input type="password" class="tpl-form-input" id="password" placeholder="请输入6位银行卡密码">
                                            <small></small>
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <label for="amount" class="am-u-sm-3 am-form-label">金额 <span class="tpl-form-line-small-title"></span></label>
                                        <div class="am-u-sm-9">
                                            <input type="text" class="tpl-form-input" id="amount" placeholder="请存款金额">
                                            <small></small>
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <div class="am-u-sm-9 am-u-sm-push-3">
                                            <button type="button" class="am-btn am-btn-primary tpl-btn-bg-color-success " onclick="deposit();">存款</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>

        

                    
                    
                </div>

               

 
                </div>



            </div>
        </div>
    </div>
    </div>


</body>

<script>

    function deposit(){
        $.ajax({
            'url' : '/card/deposit',
            'dataType' : 'json',
            'type' : 'post',
            'data' : {
                'cardId' : $('#cardId').val(),
                'password' : $('#password').val(),
                'amount' : $('#amount').val()
            },
            'success' : function (result) {
                if (result.code != 1000) {
                    alert(result.msg);
                    if (result.code == 5555) {
                        window.location.href = '/';
                    }
                    return;
                }

                alert('存钱成功');
            },
            'error' : function (result) {
                flag = true;
            }
        });
    }
    function loadMyCard() {
        $.ajax({
            'url' : '/card/loadMyCard',
            'dataType' : 'json',
            'type' : 'get',
            'data' : {
            },
            'success' : function (result) {
                if (result.code != 1000) {
                    alert(result.msg);
                    if (result.code == 5555) {
                        window.location.href = '/';
                    }
                    return;
                }
                var cards = result.data;
                var msg = '';
                for (var i=0; i<cards.length; i++) {
                    var card = cards[i];
                    msg +='<option value="'+card.cardId+'">'+card.cardNum+'</option>';
                }

                $('#cardId').html(msg);

            },
            'error' : function (result) {
                flag = true;
            }
        });
    }

    loadMyCard();
</script>

</html>